package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Permission;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface PermissionMapper {
    Page<Permission> findByCondition(String queryString);

    @Select("select * from t_permission where id=#{id}")
    Permission findById(Integer id);
 @Select("select t_permission.* from t_permission,t_role_permission where role_Id=#{id} and state=1")
    Permission findPermissionById(Integer id);


    @Insert("insert into t_permission value(#{id},#{name},#{keyword},#{state},#{creationTime},#{description})")
    void permissionAdd(Permission permission);

    @Delete("delete from t_permission where id=#{id}")
    void delete(Integer id);

   /* @Update("update t_permission set name=#{name},keyword=#{keyword},state=#{state},description=#{description} where id=#{id}")
    */
   void edit(Permission permission);
    @Select("select * from t_permission")
    List<Permission> findAll();

    @Select("select permission_Id from t_role_permission where role_Id=#{id}")
    List<Integer> findPermissionByRoleId(Integer id);


    /*@Select("select * from t_permission where id=#{id}")
    List<Role> findRoleAndPermission(Integer id);*/
}
